]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/accessibility: Export quick toggles
authorFlorian Müllner <fmuellner@gnome.org>
Sat, 7 Jun 2025 16:45:16 +0000 (18:45 +0200)
committerMarge Bot <marge-bot@gnome.org>
Fri, 27 Jun 2025 12:58:43 +0000 (12:58 +0000)
Implement quick toggles for every accessibility feature that is
currently exposed by the menu. Those toggles will eventually replace
the menu when quick setting become configurable.

However the login screen will use a dedicated accessibility menu
(once again), which does not depend on the quick settings feature,
so add the toggles now to allow implementing it.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3744>

data/gnome-shell-icons.gresource.xml
data/icons/scalable/actions/high-contrast-symbolic.svg [new file with mode: 0644]
js/ui/status/accessibility.js

index 79a7eba545e834b497b4fa669b249efb27488139..aa9bd5fb0f2b920b678b2bc8300890964f2ba697 100644 (file)
@@ -7,6 +7,7 @@
     <file preprocess="xml-stripblanks">scalable/actions/cog-wheel-symbolic.svg</file>
     <file preprocess="xml-stripblanks">scalable/actions/dark-mode-symbolic.svg</file>
     <file preprocess="xml-stripblanks">scalable/actions/group-collapse-symbolic.svg</file>
+    <file preprocess="xml-stripblanks">scalable/actions/high-contrast-symbolic.svg</file>
     <file preprocess="xml-stripblanks">scalable/actions/notification-expand-symbolic.svg</file>
     <file preprocess="xml-stripblanks">scalable/actions/ornament-check-symbolic.svg</file>
     <file preprocess="xml-stripblanks">scalable/actions/ornament-dot-checked-symbolic.svg</file>
diff --git a/data/icons/scalable/actions/high-contrast-symbolic.svg b/data/icons/scalable/actions/high-contrast-symbolic.svg
new file mode 100644 (file)
index 0000000..707c777
--- /dev/null
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 16 16" width="16px"><path d="m 8 1 l -4.5 4.5 h 0.027344 c -0.984375 1.101562 -1.527344 2.523438 -1.527344 4 c 0 3.3125 2.6875 6 6 6 s 6 -2.6875 6 -6 c 0 -1.476562 -0.546875 -2.898438 -1.53125 -4 h 0.03125 z m -0.019531 2.691406 s 0.019531 0.019532 0.019531 0.019532 v 9.921874 c -0.007812 0 -0.011719 0 -0.019531 0 c -2.21875 0 -4.015625 -1.796874 -4.015625 -4.019531 c 0 -1.019531 0.382812 -1.953125 1.007812 -2.664062 c 0.738282 -0.828125 3.007813 -3.257813 3.007813 -3.257813 z m 0 0" fill="#222222"/></svg>
index 2a98374ac724112f002e8ab08984d74275aa4e7c..b32fbe3125760793e5d605cfbd3601cac7d0fc9f 100644 (file)
@@ -5,6 +5,7 @@ import St from 'gi://St';
 
 import * as PanelMenu from '../panelMenu.js';
 import * as PopupMenu from '../popupMenu.js';
+import {QuickToggle} from '../quickSettings.js';
 
 const A11Y_SCHEMA                   = 'org.gnome.desktop.a11y';
 const KEY_ALWAYS_SHOW               = 'always-show-universal-access-status';
@@ -146,3 +147,183 @@ class ATIndicator extends PanelMenu.Button {
         return widget;
     }
 });
+
+export const HighContrastToggle = GObject.registerClass(
+class HighContrastToggle extends QuickToggle {
+    constructor() {
+        super({
+            title: _('High Contrast'),
+            iconName: 'high-contrast-symbolic',
+            toggleMode: true,
+        });
+
+        const settings = new Gio.Settings({schemaId: A11Y_INTERFACE_SCHEMA});
+        settings.bind(KEY_HIGH_CONTRAST,
+            this, 'checked',
+            Gio.SettingsBindFlags.DEFAULT);
+    }
+});
+
+export const MagnifierToggle = GObject.registerClass(
+class MagnifierToggle extends QuickToggle {
+    constructor() {
+        super({
+            title: _('Zoom'),
+            iconName: 'org.gnome.Settings-accessibility-zoom-symbolic',
+            toggleMode: true,
+        });
+
+        const settings = new Gio.Settings({schemaId: APPLICATIONS_SCHEMA});
+        settings.bind('screen-magnifier-enabled',
+            this, 'checked',
+            Gio.SettingsBindFlags.DEFAULT);
+    }
+});
+
+export const LargeTextToggle = GObject.registerClass(
+class LargeTextToggle extends QuickToggle {
+    constructor() {
+        super({
+            title: _('Large Text'),
+            iconName: 'font-x-generic-symbolic',
+            toggleMode: true,
+        });
+
+        this._settings = new Gio.Settings({schemaId: DESKTOP_INTERFACE_SCHEMA});
+        this._updateChecked();
+
+        const toggledId = this.connect('notify::checked', () => {
+            if (this.checked)
+                this._settings.set_double(KEY_TEXT_SCALING_FACTOR, DPI_FACTOR_LARGE);
+            else
+                this._settings.reset(KEY_TEXT_SCALING_FACTOR);
+        });
+
+        this._settings.connectObject(`changed::${KEY_TEXT_SCALING_FACTOR}`, () => {
+            this.block_signal_handler(toggledId);
+            this._updateChecked();
+            this.unblock_signal_handler(toggledId);
+        });
+        this._settings.bind_writable(KEY_TEXT_SCALING_FACTOR,
+            this, 'reactive',
+            false);
+    }
+
+    _updateChecked() {
+        const factor = this._settings.get_double(KEY_TEXT_SCALING_FACTOR);
+        const checked = factor > 1.0;
+        this.set({checked});
+    }
+});
+
+export const ScreenReaderToggle = GObject.registerClass(
+class ScreenReaderToggle extends QuickToggle {
+    constructor() {
+        super({
+            title: _('Screen Reader'),
+            iconName: 'audio-speakers-symbolic',
+            toggleMode: true,
+        });
+
+        const settings = new Gio.Settings({schemaId: APPLICATIONS_SCHEMA});
+        settings.bind('screen-reader-enabled',
+            this, 'checked',
+            Gio.SettingsBindFlags.DEFAULT);
+    }
+});
+
+export const ScreenKeyboardToggle = GObject.registerClass(
+class ScreenKeyboardToggle extends QuickToggle {
+    constructor() {
+        super({
+            title: _('Screen Keyboard'),
+            iconName: 'org.gnome.Settings-keyboard-symbolic',
+            toggleMode: true,
+        });
+
+        const settings = new Gio.Settings({schemaId: APPLICATIONS_SCHEMA});
+        settings.bind('screen-keyboard-enabled',
+            this, 'checked',
+            Gio.SettingsBindFlags.DEFAULT);
+    }
+});
+
+export const VisualBellToggle = GObject.registerClass(
+class VisualBellToggle extends QuickToggle {
+    constructor() {
+        super({
+            title: _('Visual Alerts'),
+            iconName: 'dialog-information-symbolic',
+            toggleMode: true,
+        });
+
+        const settings = new Gio.Settings({schemaId: WM_SCHEMA});
+        settings.bind(KEY_VISUAL_BELL,
+            this, 'checked',
+            Gio.SettingsBindFlags.DEFAULT);
+    }
+});
+
+export const StickyKeysToggle = GObject.registerClass(
+class StickyKeysToggle extends QuickToggle {
+    constructor() {
+        super({
+            title: _('Sticky Keys'),
+            iconName: 'preferences-desktop-keyboard-shortcuts-symbolic',
+            toggleMode: true,
+        });
+
+        const settings = new Gio.Settings({schemaId: A11Y_KEYBOARD_SCHEMA});
+        settings.bind(KEY_STICKY_KEYS_ENABLED,
+            this, 'checked',
+            Gio.SettingsBindFlags.DEFAULT);
+    }
+});
+
+export const SlowKeysToggle = GObject.registerClass(
+class SlowKeysToggle extends QuickToggle {
+    constructor() {
+        super({
+            title: _('Slow Keys'),
+            iconName: 'preferences-desktop-keyboard-shortcuts-symbolic',
+            toggleMode: true,
+        });
+
+        const settings = new Gio.Settings({schemaId: A11Y_KEYBOARD_SCHEMA});
+        settings.bind(KEY_SLOW_KEYS_ENABLED,
+            this, 'checked',
+            Gio.SettingsBindFlags.DEFAULT);
+    }
+});
+
+export const BounceKeysToggle = GObject.registerClass(
+class BounceKeysToggle extends QuickToggle {
+    constructor() {
+        super({
+            title: _('Bounce Keys'),
+            iconName: 'preferences-desktop-keyboard-shortcuts-symbolic',
+            toggleMode: true,
+        });
+
+        const settings = new Gio.Settings({schemaId: A11Y_KEYBOARD_SCHEMA});
+        settings.bind(KEY_BOUNCE_KEYS_ENABLED,
+            this, 'checked',
+            Gio.SettingsBindFlags.DEFAULT);
+    }
+});
+
+export const MouseKeysToggle = GObject.registerClass(
+class MouseKeysToggle extends QuickToggle {
+    constructor() {
+        super({
+            title: _('Mouse Keys'),
+            iconName: 'preferences-desktop-keyboard-shortcuts-symbolic',
+            toggleMode: true,
+        });
+
+        const settings = new Gio.Settings({schemaId: A11Y_KEYBOARD_SCHEMA});
+        settings.bind(KEY_MOUSE_KEYS_ENABLED,
+            this, 'checked',
+            Gio.SettingsBindFlags.DEFAULT);
+    }
+});